<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" />

        <title>Bdnews24.com</title>
        <link rel="stylesheet" href="stylesheets/screen.css" media="Screen" type="text/css" />
        <link rel="stylesheet" href="stylesheets/mobile.css" media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" type="text/css" />

        <!--[if IEMobile]>
        <link rel="stylesheet" href="mobile.css" media="screen" type="text/css"  />
        <![endif]-->

        <!-- These are Open Graph tags.  They add meta data to your  -->
        <!-- site that facebook uses when your content is shared     -->
        <!-- over facebook.  You should fill these tags in with      -->
        <!-- your data.  To learn more about Open Graph, visit       -->
        <!-- 'https://developers.facebook.com/docs/opengraph/'       -->

        <meta property="og:title" content="Bdnews24" />          
        <meta property="og:type" content="article" />
        <meta property="og:url" content="http://apps.facebook.com/bdnews_twenty_four/" />
        <meta property="og:image" content="http://apps.facebook.com/bdnews_twenty_four/logo.png" />
        <meta property="og:site_name" content="Bdnews24.com" /> 
        <meta property="og:description" content="Official facebook app for bdnews24" />
        <meta property="fb:app_id" content="315241705214029" />

        <script type="text/javascript" src="javascript/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="javascript/myScript.js"></script>

    </head>

    <body>

        <div id="fb-root"></div>

        <div id="content">
            <div id="pageHeading">
                <div id="heading">
                    <a href="index.php"><img src="images/heading1.gif"/></a>
                </div>

                <div id="join" onclick="requestToFriends();">
                    <a href="#" class="inviteFriend">Invite Your Friends</a>
                </div>

                <div id="e_to_b">
                    <a href="bangla_index.php"><img src="images/bangla.gif"></a>
                </div>
            </div>
        </div>
        <?php

        /**
         * 
         * @param type $category
         * @return string
         */
        function feed_to_html($category) {

            if ($category == "top_news") {

                $feed_url = "http://dev.bdnews24.com/?widgetName=rssfeed&widgetId=1150&getXmlFeed=true";
                
            } else if ($category == "bangladesh") {

                $feed_url = "http://dev.bdnews24.com/bangladesh/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true";
                
            } else if ($category == "politics") {

                $feed_url = "http://dev.bdnews24.com/politics/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true";
                
            } else if ($category == "business") {

                $feed_url = "http://dev.bdnews24.com/business/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true";
                
            } else if ($category == "sport") {

                $feed_url = "http://dev.bdnews24.com/sport/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true";
                
            } else if ($category == "world") {

                $feed_url = "http://dev.bdnews24.com/world/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true ";
                
            } else if ($category == "cricket") {

                $feed_url = "http://dev.bdnews24.com/cricket/?widgetName=rssfeed&widgetId=1210&getXmlFeed=true";
                
            }


            $content = file_get_contents($feed_url);
            $xml_data = new SimpleXMLElement($content);

            $output = '<ul style="list-style:none">';

            foreach ($xml_data->channel->item as $news) {
                $output .='<li>';

                $title = $news->title;
                $url = $news->link;
                $img_src = $news->image;

                $id = substr($url, 23);

                $image = '<img src="' . $img_src . '" height="120" width="150" />';
                $news_heading = '<a href="readArticle.php?index=' . urlencode($id) . '&category=' . $category . '">' . $title . '</a><br/>';

                $output .= $news_heading;


                $output .= $image;

                $output .='</li>';
            }
            $output .='</ul>';

            return $output;
        }

        /**
         * 
         * @param type $category
         */
        function get_heading($category) {
            if ($category == "top_news") {                
                $heading = "Today's Top News";
            } else if ($category == "bangladesh") {
                $heading = "Today's News of Bangladesh";
            } else if ($category == "politics") {
                $heading = "Today's News of Politics";
            } else if ($category == "business") {
                $heading = "Today's News of Business";
            } else if ($category == "sport") {
                $heading = "Today's News of Sport";
            } else if ($category == "world") {                
                $heading = "Today's World News";
            } else if ($category == "cricket") {
                $heading = "Today's Cricket News";
            }
            
            return $heading;
        }

        $category = $_GET['category'];

        try {
            $required_news = feed_to_html($category);
            $article_heading = get_heading($category);
        } catch (Exception $e) {
            $required_news = "can't read from feed";
        }
        ?>

        <div id="topNews">
            <h2 class="label1"><?php echo $article_heading; ?></h2>
        <?php echo $required_news; ?>
            <p class="clearfix"></p>
        </div>
        <!-- analytic data -->
        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-4785525-1']);
            _gaq.push(['_setDomainName', '.bdnews24.com']);
            _gaq.push(['_trackPageview']);
			
            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();
			
        </script>
    </body>
</html>>